codef_scrolltext.js ➔ scrolltext_horizontal   F
last analyzed

Complexity

Conditions 32

Size

Total Lines 127
Code Lines 92

Duplication

Lines 127
Ratio 100 %

Importance

Changes 0
Metric Value
cc 32
eloc 92
dl 127
loc 127
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like codef_scrolltext.js ➔ scrolltext_horizontal often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
/*------------------------------------------------------------------------------
2
Copyright (c) 2011 Antoine Santo Aka NoNameNo
3
4
This File is part of the CODEF project.
5
6
More info : http://codef.santo.fr
7
Demo gallery http://www.wab.com
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
THE SOFTWARE.
26
------------------------------------------------------------------------------*/
27
28
function ltrobj(posx,posy,ltr){
29
	this.posx=posx;
30
	this.posy=posy;
31
	this.ltr=ltr;
32
	return this;
33
}
34
35
function sortPosx(a, b) {
36
        var x = a.posx;
37
        var y = b.posx;
38
        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
39
}
40
41
function sortPosy(a, b) {
42
        var x = a.posy;
43
        var y = b.posy;
44
        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
45
}
46
47 View Code Duplication
function scrolltext_horizontal(){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
48
	this.scroffset=0;
49
	this.oldspeed=0;
50
	this.speed=1;
51
	this.font;
0 ignored issues
show
introduced by
The result of the property access to this.font is not used.
Loading history...
52
	this.letters = new Object();
53
	this.scrtxt=" ";
54
	this.pausetimer=0;
55
	this.pausedelay=0;
56
 
57
	this.init = function(dst, font,speed,sinparam,type){
58
		this.speed=speed;
59
		this.dst=dst;
60
		this.font=font;
61
		this.fontw = this.font.tilew;
62
		this.fonth = this.font.tileh;
63
		this.fontstart = this.font.tilestart;
64
		this.wide=Math.ceil(this.dst.canvas.width/this.fontw)+1;
65
		for(i=0;i<=this.wide;i++){
0 ignored issues
show
Bug introduced by
The variable i seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.i.
Loading history...
66
			this.letters[i]=new ltrobj(Math.ceil((this.wide*this.fontw)+i*this.fontw),0,this.scrtxt.charCodeAt(this.scroffset));
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like ltrobj should be capitalized.
Loading history...
67
			this.scroffset++;
68
		}
69
		if(typeof(sinparam)!='undefined')
70
                        this.sinparam=sinparam;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
71
		if(typeof(type)=='undefined')
72
                        this.type=0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
73
		else
74
			this.type=type;
75
	}
76
 
77
	this.draw = function(posy){
78
		var prov = 0;
79
		var temp = new Array();
0 ignored issues
show
Coding Style Best Practice introduced by
Using the Array constructor is generally discouraged. Consider using an array literal instead.
Loading history...
80
		var tmp=this.dst.contex.globalAlpha;
81
		this.dst.contex.globalAlpha=1;
82
		var oldvalue=new Array();
0 ignored issues
show
Coding Style Best Practice introduced by
Using the Array constructor is generally discouraged. Consider using an array literal instead.
Loading history...
83
		var i;
84
		if(typeof(this.sinparam)!='undefined'){
85
			for(var j=0;j<this.sinparam.length;j++){
86
				oldvalue[j]=this.sinparam[j].myvalue;
87
			}
88
		}
89
		if(this.speed==0){
0 ignored issues
show
Best Practice introduced by
Comparing this.speed to 0 using the == operator is not safe. Consider using === instead.
Loading history...
90
			this.pausetimer+=1;
91
			if(this.pausetimer==60*this.pausedelay){
92
				this.speed=this.oldspeed;
93
			}
94
		}
95
		var speed=this.speed;
96
		for(i=0;i<=this.wide;i++){
97
			this.letters[i].posx-=speed;
98
			if(this.letters[i].posx<=-this.fontw){
99
				if(this.scrtxt.charAt(this.scroffset) =="^"){
100
					if(this.scrtxt.charAt(this.scroffset+1) =="P"){
101
						this.pausedelay=this.scrtxt.charAt(this.scroffset+2);
102
						this.pausetimer=0;
103
						this.oldspeed=this.speed;
104
						this.speed=0;
105
						this.scroffset+=3;
106
					}
107
					else if(this.scrtxt.charAt(this.scroffset+1) =="S"){
108
						this.speed=this.scrtxt.charAt(this.scroffset+2);
109
						this.scroffset+=3;
110
					}
111
					//
112
					// ADDON by Robert Annett
113
					//
114
					else if(this.scrtxt.charAt(this.scroffset+1) =="C"){
115
						var end = this.scrtxt.indexOf(';', this.scroffset+2);
116
						var functionName = this.scrtxt.substring(this.scroffset+2, end);			
117
						window[functionName]();
118
						this.scroffset+=(end-this.scroffset)+1;
119
					}
120
				}else{
121
					this.letters[i].posx=this.wide*this.fontw+(this.letters[i].posx+this.fontw);
122
					if(typeof(this.sinparam)!='undefined'){
123
						for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 85. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
124
							oldvalue[j]+=this.sinparam[j].inc;
125
						}
126
					}
127
					this.letters[i].ltr=this.scrtxt.charCodeAt(this.scroffset);
128
					this.scroffset++;
129
					if(this.scroffset> this.scrtxt.length-1)
130
						this.scroffset=0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
131
				}
132
			}
133
		}
134
		if(typeof(this.sinparam)!='undefined'){
135
			for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 85. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
136
					this.sinparam[j].myvalue=oldvalue[j];
137
			}
138
		}
139
		
140
		for(j=0;j<=this.wide;j++){
141
			temp[j]={indice:j, posx:this.letters[j].posx};
142
		}
143
		temp.sort(sortPosx);
144
		for(i=0;i<=this.wide;i++){
145
			if(typeof(this.sinparam)!='undefined'){
146
				prov = 0;
147
				for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 85. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
148
					if(this.type==0)
0 ignored issues
show
Best Practice introduced by
Comparing this.type to 0 using the == operator is not safe. Consider using === instead.
Loading history...
149
						prov += Math.sin(this.sinparam[j].myvalue)*this.sinparam[j].amp;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
150
					if(this.type==1)
0 ignored issues
show
Best Practice introduced by
Comparing this.type to 1 using the == operator is not safe. Consider using === instead.
Loading history...
151
						prov += -Math.abs(Math.sin(this.sinparam[j].myvalue)*this.sinparam[j].amp);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
152
					if(this.type==2)
153
						prov += Math.abs(Math.sin(this.sinparam[j].myvalue)*this.sinparam[j].amp);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
154
155
				}
156
			}
157
			this.font.drawTile(this.dst,this.letters[temp[i].indice].ltr-this.fontstart,this.letters[temp[i].indice].posx,prov+posy);
158
			
159
			if(typeof(this.sinparam)!='undefined'){
160
				for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 85. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
161
					this.sinparam[j].myvalue+=this.sinparam[j].inc;
162
				}
163
			}
164
		}
165
		if(typeof(this.sinparam)!='undefined'){
166
			for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 85. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
167
					this.sinparam[j].myvalue=oldvalue[j]+this.sinparam[j].offset;
168
			}
169
		}
170
		this.dst.contex.globalAlpha=tmp;
171
	}
172
	return this;
173
}
174
175
176 View Code Duplication
function scrolltext_vertical(){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
177
	this.scroffset=0;
178
	this.oldspeed=0;
179
	this.speed=1;
180
	this.font;
0 ignored issues
show
introduced by
The result of the property access to this.font is not used.
Loading history...
181
	this.letters = new Object();
182
	this.scrtxt=" ";
183
	this.pausetimer=0;
184
	this.pausedelay=0;
185
 
186
	this.init = function(dst, font,speed,sinparam,type){
187
		this.speed=speed;
188
		this.dst=dst;
189
		this.font=font;
190
		this.fontw = this.font.tilew;
191
		this.fonth = this.font.tileh;
192
		this.fontstart = this.font.tilestart;
193
		this.wide=Math.ceil(this.dst.canvas.height/this.fonth)+1;
194
		for(i=0;i<=this.wide;i++){
0 ignored issues
show
Bug introduced by
The variable i seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.i.
Loading history...
195
			this.letters[i]=new ltrobj(0,Math.ceil((this.wide*this.fonth)+i*this.fonth),this.scrtxt.charCodeAt(this.scroffset));
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like ltrobj should be capitalized.
Loading history...
196
			this.scroffset++;
197
		}
198
		if(typeof(sinparam)!='undefined')
199
                        this.sinparam=sinparam;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
200
		if(typeof(type)=='undefined')
201
                        this.type=0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
202
		else
203
			this.type=type;
204
	}
205
 
206
	this.draw = function(posx){
207
		var prov = 0;
208
		var temp = new Array();
0 ignored issues
show
Coding Style Best Practice introduced by
Using the Array constructor is generally discouraged. Consider using an array literal instead.
Loading history...
209
		var tmp=this.dst.contex.globalAlpha;
210
		this.dst.contex.globalAlpha=1;
211
		var oldvalue=new Array();
0 ignored issues
show
Coding Style Best Practice introduced by
Using the Array constructor is generally discouraged. Consider using an array literal instead.
Loading history...
212
		var i;
213
		if(typeof(this.sinparam)!='undefined'){
214
			for(var j=0;j<this.sinparam.length;j++){
215
				oldvalue[j]=this.sinparam[j].myvalue;
216
			}
217
		}
218
		if(this.speed==0){
0 ignored issues
show
Best Practice introduced by
Comparing this.speed to 0 using the == operator is not safe. Consider using === instead.
Loading history...
219
			this.pausetimer+=1;
220
			if(this.pausetimer==60*this.pausedelay){
221
				this.speed=this.oldspeed;
222
			}
223
		}
224
		var speed=this.speed;
225
		for(i=0;i<=this.wide;i++){
226
			this.letters[i].posy-=speed;
227
			if(this.letters[i].posy<=-this.fonth){
228
				if(this.scrtxt.charAt(this.scroffset) =="^"){
229
					if(this.scrtxt.charAt(this.scroffset+1) =="P"){
230
						this.pausedelay=this.scrtxt.charAt(this.scroffset+2);
231
						this.pausetimer=0;
232
						this.oldspeed=this.speed;
233
						this.speed=0;
234
						this.scroffset+=3;
235
					}
236
					else if(this.scrtxt.charAt(this.scroffset+1) =="S"){
237
						this.speed=this.scrtxt.charAt(this.scroffset+2);
238
						this.scroffset+=3;
239
					}
240
					//
241
					// ADDON by Robert Annett
242
					//
243
					else if(this.scrtxt.charAt(this.scroffset+1) =="C"){
244
						var end = this.scrtxt.indexOf(';', this.scroffset+2);
245
						var functionName = this.scrtxt.substring(this.scroffset+2, end);			
246
						window[functionName]();
247
						this.scroffset+=(end-this.scroffset)+1;
248
					}
249
				}else{
250
					this.letters[i].posy=this.wide*this.fonth+(this.letters[i].posy+this.fonth);
251
					if(typeof(this.sinparam)!='undefined'){
252
						for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 214. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
253
							oldvalue[j]+=this.sinparam[j].inc;
254
						}
255
					}
256
					this.letters[i].ltr=this.scrtxt.charCodeAt(this.scroffset);
257
					this.scroffset++;
258
					if(this.scroffset> this.scrtxt.length-1)
259
						this.scroffset=0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
260
				}
261
			}
262
		}
263
		if(typeof(this.sinparam)!='undefined'){
264
			for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 214. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
265
					this.sinparam[j].myvalue=oldvalue[j];
266
			}
267
		}
268
		
269
		for(j=0;j<=this.wide;j++){
270
			temp[j]={indice:j, posy:this.letters[j].posy};
271
		}
272
		temp.sort(sortPosy);
273
		for(i=0;i<=this.wide;i++){
274
			if(typeof(this.sinparam)!='undefined'){
275
				prov = 0;
276
				for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 214. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
277
					if(this.type==0)
0 ignored issues
show
Best Practice introduced by
Comparing this.type to 0 using the == operator is not safe. Consider using === instead.
Loading history...
278
						prov += Math.sin(this.sinparam[j].myvalue)*this.sinparam[j].amp;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
279
					if(this.type==1)
0 ignored issues
show
Best Practice introduced by
Comparing this.type to 1 using the == operator is not safe. Consider using === instead.
Loading history...
280
						prov += -Math.abs(Math.sin(this.sinparam[j].myvalue)*this.sinparam[j].amp);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
281
					if(this.type==2)
282
						prov += Math.abs(Math.sin(this.sinparam[j].myvalue)*this.sinparam[j].amp);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
283
				}
284
			}
285
			this.font.drawTile(this.dst,this.letters[temp[i].indice].ltr-this.fontstart,prov+posx,this.letters[temp[i].indice].posy);
286
			
287
			if(typeof(this.sinparam)!='undefined'){
288
				for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 214. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
289
					this.sinparam[j].myvalue+=this.sinparam[j].inc;
290
				}
291
			}
292
		}
293
		if(typeof(this.sinparam)!='undefined'){
294
			for(var j=0;j<this.sinparam.length;j++){
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable j already seems to be declared on line 214. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
295
					this.sinparam[j].myvalue=oldvalue[j]+this.sinparam[j].offset;
296
			}
297
		}
298
		this.dst.contex.globalAlpha=tmp;
299
	}
300
	return this;
301
}
302
303